import Taro, { useDidShow } from "@tarojs/taro";
import { useState } from "react";
// import { useState, useEffect } from "react";
import { View ,Image} from "@tarojs/components";
// import { AtTabs, AtTabsPane } from "taro-ui";
import {Empty,SubmitBar} from "@antmjs/vantui";
import r from "../../../static/R.jpg"
import "./application.scss";

const Application = () => {
  const [data, setData] = useState([]);

  useDidShow(async () => {
    await Taro.cloud
      .callFunction({
        name: "logins",
        data: {
          $url: "myApplication"
        }
      })
      .then((res: any) => {
        console.log("请求成功", res);
        setData(res.result.data);
        setApplication(res.result.data);
        // setMenuList(res.result.data)
      });
  });

  //noncontent
  const [noncontent] = useState([
    {
      content: "没有更多的内容了"
    }
  ]);
  const Noncontent = noncontent.map(contnet => (
    <View className="noncontent">
      <Empty description={contnet.content} />
    </View>
  ));

  const [application, setApplication] = useState([
    // {
    //   image: r,
    //   name: "作品名字哈哈哈哈哈哈哈哈哈哈"
    // },
    // {
    //   image: r,
    //   name: "作品名字"
    // },
    // {
    //   image: r,
    //   name: "作品名字"
    // }
  ]);
  const Application=data && data.length > 0
  ?application.map(content=>(
    <View className="application">
      <Image  src={content.copyrightchart} mode="aspectFill" className="image"></Image>
      <View className="name">{content.workName}</View>
    </View>
  )):Noncontent;

  return (
    <View className="box">
      <View className="index">
        <View className="center">申请的版权数：{data.length}</View>
      </View>

      <View className="application_box">{Application}</View>
    </View>
  );
};

export default Application;
